package com.tencreat.service.mall.impl;

import java.time.LocalDateTime;
import java.util.List;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.domain.mall.MallStorage;
import org.springframework.stereotype.Service;
import com.tencreat.mapper.mall.MallStorageMapper;
import com.tencreat.service.mall.IMallStorageService;

/**
 * 文件存储Service业务层处理
 *
 * @author tencreat
 * @date 2021-08-13
 */
@Service
public class MallStorageServiceImpl extends ServiceImpl<MallStorageMapper, MallStorage> implements IMallStorageService {


    /**
     * 查询文件存储
     *
     * @param id 文件存储ID
     * @return 文件存储
     */
    @Override
    public MallStorage selectMallStorageById(ReqIdParam id) {
        return baseMapper.selectById(id.getId());
    }

    /**
     * 查询文件存储列表
     *
     * @param mallStorage 文件存储
     * @return 文件存储
     */
    @Override
    public List<MallStorage> selectMallStorageList(MallStorage mallStorage) {
        return baseMapper.selectList(Wrappers.query(mallStorage));
    }

    /**
     * 新增文件存储
     *
     * @param mallStorage 文件存储
     * @return 结果
     */
    @Override
    public int insertMallStorage(MallStorage mallStorage) {
        mallStorage.setCreateTime(LocalDateTime.now());
        return baseMapper.insert(mallStorage);
    }

    /**
     * 修改文件存储
     *
     * @param mallStorage 文件存储
     * @return 结果
     */
    @Override
    public int updateMallStorage(MallStorage mallStorage) {
        mallStorage.setUpdateTime(LocalDateTime.now());
        return baseMapper.updateById(mallStorage);
    }

    /**
     * 批量删除文件存储
     *
     * @param ids 需要删除的文件存储ID
     * @return 结果
     */
    @Override
    public int deleteMallStorageByIds(ReqIdsParam ids) {
        return baseMapper.deleteBatchIds(ids.getId());
    }

    /**
     * 删除文件存储信息
     *
     * @param id 文件存储ID
     * @return 结果
     */
    @Override
    public int deleteMallStorageById(ReqIdParam id) {
        return baseMapper.deleteById(id.getId());
    }
}
